/**
 * 订单发货
 * 
 * @return {}
 */
var orderSended = new Ext.LoadMask(Ext.getBody(), {
			msg : "正在提交,请稍后..."
		});
var queryOrderSendedSearch = function() {
	var queryOrdersSendedFieldSet = new Ext.form.FieldSet({
				id : 'queryOrdersSendedFieldSet',
				title : '查询条件',
				collapsible : true,// 可折叠
				buttonAlign : 'center',
				keys : [{
							key : 13, // 13代表回车
							fn : queryOrdersSended,
							scope : this
						}],
				items : [{
					layout : 'column',
					border : false,
					items : [{
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{
											xtype : 'textfield',
											name : 'id',
											anchor : '100%',
											fieldLabel : '订单编号'
										}]
							}, {
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{
											xtype : 'textfield',
											anchor : '100%',
											fieldLabel : '订单编码',
											name : "orderCode"
										}]
							}, {
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{

									xtype : 'datefield',
									fieldLabel : '配送开始时间',
									editable : false,
									format : "Y-m-d",
									anchor : "100%",
									width : 175,
									id : 'sended_startDate',
									name : "deliveryDateStart",
									listeners : {
										'select' : function() {
											Ext.getCmp('sended_endDate')
													.setMinValue(this
															.getValue());
										}
									}

								}]
							}, {
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{

									xtype : 'datefield',
									fieldLabel : '配送结束时间',
									editable : false,
									format : "Y-m-d",
									anchor : "100%",
									width : 175,
									id : 'sended_endDate',
									name : "deliveryDateEnd",
									listeners : {
										'select' : function() {
											Ext.getCmp('sended_startDate')
													.setMaxValue(this
															.getValue());
										}
									}

								}]
							}]
				}, {
					layout : 'column',
					border : false,
					items : [{
								columnWidth : .25,
								layout : 'form',
								border : false,
								items : [{
											xtype : 'dataDictionaryCmb',
											anchor : '100%',
											fieldLabel : "订单类型",
											editable : false,
											autoLoad : false,
											existall : true,
											defaultFirstRow : 1,
											hiddenName : 'orderType',
											dictionaryType : PmsUtil.order_type
										}]
							}, {
								columnWidth : .25,
								layout : 'column',
								border : false,
								items : [{
											text : '查询',
											xtype : 'button',
											width : 70,
											handler : function() {
												queryOrdersSended();
											},
											style : {
												marginLeft : "100px",
												marginRight : "10px"
											}
										}, {
											text : '重置',
											xtype : 'button',
											width : 70,
											handler : function() {
												queryOrderSendedForm.getForm()
														.reset();
											}
										}]
							}]
				}]
			});
	fieldSetListeners(['queryOrdersSendedFieldSet', 'queryOrderSendedForm',
					'orderManagerGrid'], [0.16, 0.84]);

	var queryOrderSendedForm = new Ext.form.FormPanel({
				id : 'queryOrderSendedForm',
				anchor : '100% 16%',
				frame : true,
				labelAlign : 'right',
				bodyBorder : false,
				items : [queryOrdersSendedFieldSet]
			});
	return queryOrderSendedForm;
};

/**
 * grids
 */
var orderSendedManagerGrid = function() {
	var orderSendedSm = new Ext.grid.CheckboxSelectionModel({
				checkOnly : true,
				renderer : function(v, p, record) {
					var orderStatus = record.get('orderStatus');
					if (orderStatus != PmsUtil.ORDER_STATUS_COMLETER) {
						return '<div class="x-grid3-row-checker">&#160;</div>';
					} else {
						return '';
					}
				},
				listeners : {
					beforerowselect : function(SelectionModel, rowIndex,
							keepExisting, record) {
						var orderStatus = record.get('orderStatus');
						if (orderStatus != PmsUtil.ORDER_STATUS_COMLETER) {
							return true;
						} else {
							return false;
						}
					}
				}
			});
	// 定义表的每列（对应表头信息）
	var orderSendedCm = new Ext.grid.ColumnModel([orderSendedSm, {
				dataIndex : "id",
				header : "订单编号",
				sortable : false,
				width : 60
			}, {
				dataIndex : "orderCode",
				header : "订单编码",
				sortable : false,
				width : 160,
				renderer : function(value, cellmeta, record, rowIndex,
						columnIndex, store) {
					var returnValue = "";
					var orderId = record.data.id;
					if (value) {
						returnValue = '<a href ="#" onClick="lookOrderSendedDetail(\''
								+ orderId + '\')">' + value + '</a>';
					}
					return returnValue;
				}
			}, {
				dataIndex : "deliveryDate",
				header : "配送日期",
				sortable : false,
				width : 80,
				renderer : function(date) {
					return '<font color=\"#FF0000\" >'
							+ Ext.util.Format.substr(date, 0, 10) + '</font>';
				}
			}, {
				dataIndex : "deliveryTimes",
				header : "配送时间段",
				sortable : true,
				width : 90,
				renderer : function(value) {
					return '<font color=\"#FF0000\" >' + value + '</font>';
				}
			}, {
				dataIndex : "orderType",
				header : "订单类型",
				sortable : false,
				width : 70,
				renderer : function(value) {
					return PmsUtil.OrderType(value);
				}
			}, {
				dataIndex : "orderStatus",
				header : "订单状态",
				sortable : false,
				width : 60,
				renderer : function(value) {
					if (value) {
						return '<font color=\"#FF0000\" >'
								+ PmsUtil.OrderStatus(value) + '</font>';
					}
				}
			}, {
				dataIndex : "payAmount",
				header : "订单金额",
				sortable : false,
				width : 70,
				renderer : function(value) {
					return PmsUtil.Price(value);
				}
			}, {
				dataIndex : "deliveryFee",
				header : "配送费用",
				sortable : false,
				width : 60,
				renderer : function(value) {
					return PmsUtil.Price(value);
				}
			}, {
				dataIndex : "remark",
				header : "备注",
				sortable : false,
				width : 100,
				renderer : function(value, meta, record) {
					if (value) {
						meta.attr = 'ext:qtitle="备注:" ext:qtip="' + value + '"';
						return '<font color=\"#FF0000\" >' + value + '</font>';;
					}
				}
			}, {
				dataIndex : "birthdayCard",
				header : "生日卡片",
				sortable : false,
				width : 80,
				renderer : function(value) {
					if (value) {
						var div = '<div ext:qtitle="生日卡片:" ext:qtip="{0}">{0}</div>';
						return '<font color=\"#FF0000\" >'
								+ String.format(div, value) + '</font>';
					}
				}
			}, {
				dataIndex : "logisticMessage",
				header : "最新物流信息",
				sortable : false,
				width : 160,
				renderer : function(value, meta, record) {
					if (value) {
						meta.attr = 'ext:qtitle="最新物流信息:" ext:qtip="' + value
								+ '"';
						return value;
					}
				}
			}, {
				dataIndex : "goodsNumber",
				header : "商品数量",
				sortable : false,
				width : 60
			}, {
				dataIndex : "consignee",
				header : "收货人",
				sortable : false,
				width : 70
			}, {
				dataIndex : "consignPhone",
				header : "收货人电话",
				sortable : false,
				width : 100
			}, {
				dataIndex : "consignAddress",
				header : "收货人地址",
				sortable : false,
				width : 180,
				renderer : function(value, meta, record) {
					if (value) {
						meta.attr = 'ext:qtitle="收货人地址:" ext:qtip="' + value
								+ '"';
						return value;
					}
				}
			}, {
				dataIndex : "createdDate",
				header : "创建时间",
				sortable : false,
				width : 130
			}, {
				header : "管理",
				width : 480,
				dataIndex : "id",
				renderer : function(j, i, g, m, h) {
					var orderId = g.data.id;
					var orderStatus = g.data.orderStatus;
					var orderType = g.data.orderType;
					var k = "";
					if (isGranted("orderSended_热敏单个打印")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="printThermalOrderSend('
								+ orderId + ')\">热敏打印</a>';
					}
					if (isGranted("orderSended_订单打印")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="printOrder('
								+ orderId + ')\">订单打印</a>';
					}
					if (orderStatus == 4 && isGranted("orderSended_单个完成")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="updateOrderSendedStatusOne('
								+ orderId
								+ ','
								+ "5"
								+ ','
								+ "'已完成'"
								+ ')\">完成</a>';
					}

					if (orderStatus == 4 && isGranted("orderSended_填写物流单号")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="addLogisticNo('
								+ orderId + ')\">填写物流单号</a>';
					}
					if (isGranted("orderSended_配送信息")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="addDeliveryInfo('
								+ orderId + ')\">填写配送信息</a>';
					}
					if (isGranted("orderSended_物流状态")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="orderSendLookLogisticStatus('
								+ orderId + ')\">物流状态</a>';
					}
					if (orderStatus == 4 && isGranted("orderSended_修改订单")) {
						k += '&nbsp;&nbsp;<a href="#" onclick="updateOrderSended('
								+ orderId + ')\">修改订单</a>';
					}
					if (orderStatus == 4 && isGranted("orderSended_拒收")) {
						if (orderType == 3 || orderType == 2) {
							k += '&nbsp;&nbsp;<a href="#" onclick="refuseReceive('
									+ orderId + ',' + orderType + ')\">拒收</a>';
						} else {
							k += '&nbsp;&nbsp;<a href="#" onclick="refuseReceive('
									+ orderId
									+ ','
									+ orderStatus
									+ ','
									+ orderType + ')\">拒收并退款</a>';
						}
					}

					return k;
				}
			}]);

	// 定义分析器
	var orderManagerReader = new Ext.data.JsonReader({
				totalProperty : "totalCount",
				root : "list",
				fields : [{
							name : "id"
						}, {
							name : "orderCode"
						}, {
							name : "userPaymentId"
						}, {
							name : "orderStatus"
						}, {
							name : "payStatus"
						}, {
							name : "payType"
						}, {
							name : "payDate"
						}, {
							name : "limitPayDate"
						}, {
							name : "totalAmount"
						}, {
							name : "goodsNumber"
						}, {
							name : "payAmount"
						}, {
							name : "deliveryDate"
						}, {
							name : "deliveryTimes"
						}, {
							name : "deliveryFee"
						}, {
							name : "isUserCoupon"
						}, {
							name : "couponId"
						}, {
							name : "couponFee"
						}, {
							name : "consignee"
						}, {
							name : "consignPhone"
						}, {
							name : "consignAddress"
						}, {
							name : "birthdayTitle"
						}, {
							name : 'logisticNo'
						}, {
							name : "logisticMessage"
						}, {
							name : "birthdayCard"
						}, {
							name : "remark"
						}, {
							name : "payGoodsName"
						}, {
							name : "createdDate"
						}, {
							name : "createdName"
						}, {
							name : "orderType"
						}]
			});

	// 取数据store
	var orderSendedViewStore = new Ext.data.Store({
				autoLoad : true,// 要加载数据必须设置为true
				proxy : new Ext.data.HttpProxy({
							url : __ctxPath + "/orderManager/selectOrders"
						}),
				remoteSort : true,
				baseParams : {
					start : 0,
					limit : 25,
					orderStatus : '4'
				},
				listeners : {
					beforeload : {
						fn : function(thiz, options) {
							Ext.apply(thiz.baseParams, Ext
											.getCmp('queryOrderSendedForm')
											.getForm().getValues());
						}
					}
				},
				reader : orderManagerReader
			});
	orderSendedViewStore.setDefaultSort("od.delivery_date", "asc");
	var orderSendedTb = new Ext.Toolbar({// 定义grid的toolbar
		height : 25,
		items : []
	});
	orderSendedTb.add(new Ext.scm.Button({
				text : "批量完成",
				width : 80,
				hsValue : 'orderSended_批量完成',
				pressed : true,
				iconCls : "btn-edit",
				handler : function() {
					batchOrderSendedUpdateStatus(5, '已完成');
				}
			}));
	orderSendedTb.add(new Ext.Toolbar.Spacer());
	orderSendedTb.add(new Ext.scm.Button({
				text : "热敏打印",
				width : 80,
				hsValue : 'orderSended_热敏批量打印',
				pressed : true,
				iconCls : "btn-print",
				handler : function() {
					batchPrintThermalOrderSend();
				}
			}));

	orderSendedTb.add(new Ext.Toolbar.Spacer());
	orderSendedTb.add(new Ext.scm.Button({
				text : "交接单打印",
				width : 80,
				hsValue : 'orderSended_交接单打印',
				pressed : true,
				iconCls : "btn-print",
				handler : function() {
					batchPrintHandOverOrder();
				}
			}));

	orderSendedTb.add(new Ext.scm.Button({
				text : "配送单打印",
				width : 90,
				hsValue : 'orderSended_配送单批量打印',
				pressed : true,
				iconCls : "btn-print",
				handler : function() {
					batchPrintSendedDeliveryOrder();
				}
			}));

	orderSendedTb.add(new Ext.Toolbar.Spacer());
	orderSendedTb.add(new Ext.scm.Button({
				text : "刷 新",
				width : 80,
				hsValue : 'orderSended_刷新',
				iconCls : "btn-refresh",
				pressed : true,
				handler : function() {
					queryOrdersSended();
				}
			}));
	var orderSendedManagerGrid = new Ext.grid.GridPanel({
				id : 'orderSendedManagerGrid',
				store : orderSendedViewStore,
				cm : orderSendedCm,
				sm : orderSendedSm,
				autoScroll : true,
				loadMask : true,
				stripeRows : true,
				columnLines : true,
				loadMask : {
					msg : "正在加载数据，请稍侯……"
				},
				viewConfig : {
					emptyText : '没有您想要的数据!'
				},
				anchor : '100% 84%',
				frame : true,
				tbar : orderSendedTb,
				bbar : new PG.PagingBar({
							id : 'orderSendedGridPage',
							store : orderSendedViewStore
						})
			});
	return orderSendedManagerGrid;
};

// 查询
function queryOrdersSended() {
	if (Ext.getCmp('queryOrderSendedForm').getForm().isValid()) {
		var grid = Ext.getCmp('orderSendedManagerGrid');
		var store = grid.store;
		var pagesize = Ext.getCmp('orderSendedGridPage').pageSize;
		store.load({
					params : {
						start : 0,
						limit : pagesize,
						"orderStatusArray" : '3'
					}
				});
	}
}

/**
 * 订单单个发货
 * 
 * @param {}
 *            orderId
 * @param {}
 *            orderStatus
 * @param {}
 *            statusName
 */
function updateOrderSendedStatusOne(orderId, orderStatus, statusName) {
	Ext.Msg.confirm("信息确认", "您确定要将订单状态变更为<span style='color:#F00'>"
					+ statusName + "</span>？", function(c) {
				if (c == "yes") {
					commonOrderSendedUpateOrder(orderId, orderStatus,
							statusName);
				}
			});
}

/**
 * 查询订单详情
 * 
 * @param {}
 *            id
 */
function lookOrderSendedDetail(id) {
	var centerPanel = App.getContentPanel();
	var tab = centerPanel.getItem(PmsUtil.ORDER_MESSAGE_DETAIL);
	var createNewTab = new CreatNewTab(PmsUtil.ORDER_MESSAGE_DETAIL, '订单详情');
	if (tab == null) {
		createNewTab.createNew(tab);
	} else {
		createNewTab.createOld(tab, ['lookOrderDetailFields',
						'lookOrderDetailForm', 'lookOrderDetailGrid']);
	}
	Ext.Loader.load([__ctxPath + '/js/order/orderDetail.js'], function() {
				Ext.getCmp("centerTabPanel").getActiveTab().add(
						lookOrderDetailSearch(id), orderDetailGrid(id));
				Ext.getCmp("centerTabPanel").getActiveTab().doLayout();
			});
}

/**
 * 批量修改订单状态
 */
function batchOrderSendedUpdateStatus(orderStatus, statusName) {
	var d = Ext.getCmp("orderSendedManagerGrid");
	var jsonrecord = d.getSelectionModel().getSelections();
	if (jsonrecord.length == 0) {
		Ext.MessageBox.show({
					title : "操作信息",
					msg : "请选择要完成的订单!",
					buttons : Ext.MessageBox.OK,
					icon : Ext.MessageBox.WARNING
				});
		return;
	}
	Ext.Msg.confirm("信息确认", "您确定要将订单状态变更为<span style='color:#F00'>"
					+ statusName + "</span>？", function(c) {
				if (c == "yes") {
					var orderIds = "";
					var m = 0;
					for (var i = 0; i < jsonrecord.length; i++) {
						var tmp = jsonrecord[i];
						if (m > 0) {
							orderIds = orderIds + "," + tmp.data.id;
						} else {
							orderIds = tmp.data.id;
						}
						m++;
					}
					commonOrderSendedUpateOrder(orderIds, orderStatus,
							statusName);
				}
			});
}

/**
 * 公用修改订单状态方法
 * 
 * @param {}
 *            orderIds
 * @param {}
 *            orderStatus
 * @param {}
 *            statusName
 */
function commonOrderSendedUpateOrder(orderIds, orderStatus, statusName) {
	orderSended.show();
	Ext.Ajax.request({
				url : __ctxPath + "/orderManager/updateOrderStatus",
				params : {
					orderIds : orderIds,
					orderStatus : orderStatus,
					statusName : statusName,
					cancelReason : ''
				},
				method : "post",
				success : function(response, config) {
					orderSended.hide();
					var jsonData = Ext.util.JSON.decode(response.responseText);
					if (jsonData.success) {
						Ext.MessageBox.show({
									title : "信息提示",
									msg : "修改订单状态成功!",
									buttons : Ext.MessageBox.OK,
									icon : Ext.MessageBox.INFO
								});
						queryOrdersSended();
					} else {
						Ext.MessageBox.show({
									title : "操作信息",
									msg : "修改订单状态失败!",
									buttons : Ext.MessageBox.OK,
									icon : Ext.MessageBox.ERROR
								});
					}
				},
				failure : function(response, config) {
					orderSended.hide();
					Ext.MessageBox.show({
								title : "错误提示",
								msg : "服务器请求异常，请稍后再试!",
								buttons : Ext.MessageBox.OK,
								icon : Ext.MessageBox.ERROR
							});
				}
			});
}

/**
 * 填写物流单号
 * 
 * @param {}
 *            orderId
 */
function addLogisticNo(orderId) {
	try {
		addLogisticNoWindows(orderId).show();
	} catch (Error) {
		Ext.Loader.load([__ctxPath + '/js/order/logisticNo.js'], function() {
					addLogisticNoWindows(orderId).show();
				});
	}

}
/**
 * 填写物流配送员信息
 * 
 * @param {}
 *            orderId
 */
function addDeliveryInfo(orderId) {
	try {
		addDeliveryInfoWindows(orderId).show();
	} catch (Error) {
		Ext.Loader.load([__ctxPath + '/js/order/deliveryInfoWin.js'],
				function() {
					addDeliveryInfoWindows(orderId).show();
				});
	}

}
/**
 * 订单打印
 * 
 * @param {}
 *            orderId
 */
function printOrder(orderId) {
	window.open(__ctxPath + "/orderManager/printOrder?orderId=" + orderId,
			"_blank");
}
/**
 * 订单热敏打印
 * 
 * @param {}
 *            orderId
 */
function printThermalOrderSend(orderId) {
	window.open(__ctxPath + "/orderManager/printThermalOrder?orderId="
					+ orderId, "_blank");
}
/**
 * 批量打印
 */
function batchPrintThermalOrderSend() {
	var d = Ext.getCmp("orderSendedManagerGrid");
	var jsonrecord = d.getSelectionModel().getSelections();
	if (jsonrecord.length == 0) {
		Ext.MessageBox.show({
					title : "操作信息",
					msg : "请选择要打印的订单!",
					buttons : Ext.MessageBox.OK,
					icon : Ext.MessageBox.WARNING
				});
		return;
	}
	var orderIds = "";
	var m = 0;
	for (var i = 0; i < jsonrecord.length; i++) {
		var tmp = jsonrecord[i];
		if (m > 0) {
			orderIds = orderIds + "," + tmp.data.id;
		} else {
			orderIds = tmp.data.id;
		}
		m++;
	}
	printThermalOrderSend(orderIds);

}

// 交接单打印
function batchPrintHandOverOrder() {
	var d = Ext.getCmp("orderSendedManagerGrid");
	var jsonrecord = d.getSelectionModel().getSelections();
	if (jsonrecord.length == 0) {
		Ext.MessageBox.show({
					title : "操作信息",
					msg : "请选择要打印的订单!",
					buttons : Ext.MessageBox.OK,
					icon : Ext.MessageBox.WARNING
				});
		return;
	}

	var orderIds = "";
	var m = 0;
	for (var i = 0; i < jsonrecord.length; i++) {
		var tmp = jsonrecord[i];
		if (m > 0) {
			orderIds = orderIds + "," + tmp.data.id;
		} else {
			orderIds = tmp.data.id;
		}
		m++;
	}
	window.open(__ctxPath + "/orderManager/printHandOverOrder?orderIds="
					+ orderIds, "_blank");

};

// 配送单打印
function batchPrintSendedDeliveryOrder() {
	var d = Ext.getCmp("orderSendedManagerGrid");
	var jsonrecord = d.getSelectionModel().getSelections();
	if (jsonrecord.length == 0) {
		Ext.MessageBox.show({
					title : "操作信息",
					msg : "请选择要打印的订单!",
					buttons : Ext.MessageBox.OK,
					icon : Ext.MessageBox.WARNING
				});
		return;
	}

	var orderIds = "";
	var m = 0;
	for (var i = 0; i < jsonrecord.length; i++) {
		var tmp = jsonrecord[i];
		if (m > 0) {
			orderIds = orderIds + "," + tmp.data.id;
		} else {
			orderIds = tmp.data.id;
		}
		m++;
	}
	printSendedDeliveryOrder(orderIds);
};

// 单个配送单打印
function printSendedDeliveryOrder(orderIds) {
	window.open(__ctxPath + "/orderManager/printDeliveryOrder?orderIds="
					+ orderIds, "_blank");
}

/**
 * 查询物流状态列表
 * 
 * @param {}
 *            id
 */
function orderSendLookLogisticStatus(id) {
	var centerPanel = App.getContentPanel();
	var tab = centerPanel.getItem(PmsUtil.LOGISTIC_STATUS);
	var createNewTab = new CreatNewTab(PmsUtil.LOGISTIC_STATUS, '物流状态');
	if (tab == null) {
		createNewTab.createNew(tab);
	} else {
		createNewTab.createOld(tab, ['logisticStatusGrid']);
	}
	Ext.Loader.load([__ctxPath + '/js/order/logisticStatus.js'], function() {
		Ext.getCmp("centerTabPanel").getActiveTab().add(logisticStatusGrid(id));
		Ext.getCmp("centerTabPanel").getActiveTab().doLayout();
	});
}

/**
 * 修改订单
 * 
 * @param {}
 *            orderId
 */
function updateOrderSended(orderId) {
	try {
		updateOrderWin(orderId, 'orderSendedManagerGrid').show();
	} catch (Error) {
		Ext.Loader.load([__ctxPath + '/js/order/orderForm.js'], function() {
					updateOrderWin(orderId, 'orderSendedManagerGrid').show();
				});
	}
}

/**
 * 拒收/拒收并退款
 * 
 * @param {}
 *            orderId
 */
function refuseReceive(orderId, nowOrderStatus, orderType) {
	refuseReceiveStatusRemark(orderId,nowOrderStatus, orderType).show();
}

function refuseReceiveStatusRemark(orderId,nowOrderStatus, orderType) {
	var refuseReceiveOrerderForm = new Ext.FormPanel({
		id : "refuseReceiveOrerderForm",
		frame : true,
		bodyBorder : false,
		defaultType : "textarea",
		items : [{
					name : "id",
					xtype : "hidden",
					value : orderId
				}, new Ext.form.NumberField({
							xtype : 'textfield',
							name : 'refundsPrice',
							fieldLabel : "<span style='color:#F00'>*</span>申请退款金额",
							allowBlank : false,
							blankText : '申请退款金额不能为空',
							minValue : 0.1, // 最小值
							minText : '申请退款金额应大于0.1',
							anchor : '100%'
						}), {
					xtype : 'textarea',
					fieldLabel : "<span style='color:#F00'>*</span>拒收原因备注",
					name : "refundsReason",
					allowBlank : false,
					vtype : "validateMaxLength",
					confirmTo : 500,
					anchor : '100%',
					height : 120
				}]
	});
	var refuseReceiveWindow = new Ext.Window({
		id : "refuseReceiveWindow",
		title : "拒收备注",
		width : 400,
		height : 260,
		closable : true,
		modal : true,
		layout : "fit",
		autoDestroy : true,
		plain : true,
		buttonAlign : "center",
		items : refuseReceiveOrerderForm,
		buttons : [{
			text : "保存",
			width : 60,
			handler : function() {
				var orderStatus;
				if (orderType == 3 || orderType == 2) {
					orderStatus = 10;
				} else {
					orderStatus = 7;
				}
				var uploadForm = refuseReceiveOrerderForm.getForm();
				if (uploadForm.isValid()) {
					Ext.Msg.confirm("信息确认", "确认要拒收吗？", function(c) {
						if (c == "yes") {
							uploadForm.submit({
								url : __ctxPath + "/orderManager/refuseReceive",
								params : {
									orderId : orderId,
									orderStatus : orderStatus,
									orderType : orderType,
									beforeRefundOrderStatus : nowOrderStatus
								},
								method : "post",
								waitTitle : "请稍后",
								waitMsg : "正在提交数据...",
								success : function(response, options) {
									queryOrdersSended();
									refuseReceiveWindow.close();
									var jsonData = Ext.util.JSON
											.decode(options.response.responseText);
									Ext.MessageBox.show({
												title : "信息提示",
												msg : jsonData.data,
												buttons : Ext.MessageBox.OK,
												icon : Ext.MessageBox.INFO
											});
								},
								failure : function(response, options) {
									var jsonData = Ext.util.JSON
											.decode(options.response.responseText);
									Ext.MessageBox.show({
												title : "操作信息",
												msg : jsonData.data,
												buttons : Ext.MessageBox.OK,
												icon : Ext.MessageBox.ERROR
											});
									refuseReceiveWindow.close();
								}
							});
						}
					})
				}
			}
		}, {
			text : "重置",
			width : 60,
			handler : function() {
				refuseReceiveOrerderForm.form.reset();
			}
		}, {
			text : "取消",
			width : 60,
			handler : function() {
				refuseReceiveWindow.close();
			}
		}]
	});
	return refuseReceiveWindow;
}

Ext.getCmp("centerTabPanel").getActiveTab().add(queryOrderSendedSearch(),
		orderSendedManagerGrid());
Ext.getCmp("centerTabPanel").getActiveTab().doLayout();